package cn.tedu.csmall.all.adapter.consumer;

import cn.tedu.csmall.all.service.ICartService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(topic = "order-add-topic",
consumerGroup = "${rocketmq.consumer.group}",
selectorExpression = "*")
public class CartDeleteConsumerListener implements RocketMQListener<String> {

    @Autowired(required = false)
    private ICartService cartService;

    public void onMessage(String msg) {
        String userId=msg.split(":")[0];
        String commodityCode=msg.split(":")[1];
        //删除购物车
        cartService.deleteUserCartCommodity(userId,commodityCode);
    }
}
